from rest_framework import serializers

from apps.areas.models import Area
from apps.users.models import Address


# 这是关于省市区的序列化器
class AreaSerializer(serializers.ModelSerializer):
    class Meta:
        model = Area
        fields = '__all__'


# 这是关于收获地址的序列化器
class AddressSerializer(serializers.ModelSerializer):
    user_id = serializers.IntegerField()
    province_id = serializers.IntegerField()
    district_id = serializers.IntegerField()
    city_id = serializers.IntegerField()
    user = serializers.CharField(max_length=100, read_only=True)
    province = serializers.CharField(max_length=100, read_only=True)
    district = serializers.CharField(max_length=100, read_only=True)
    city = serializers.CharField(max_length=100, read_only=True)

    class Meta:
        model = Address
        fields = '__all__'
